package com.xjnt.base.support.admin.controller;

import com.xjnt.base.support.admin.entity.Account;
import com.xjnt.base.support.admin.service.AccountService;
import com.xjnt.base.support.admin.service.InitialService;
import com.xjnt.base.support.admin.service.UserService;
import com.xjnt.frameworks.annotation.AutoInject;
import com.xjnt.frameworks.annotation.Router;
import com.xjnt.frameworks.core.BaseController;
import com.xjnt.frameworks.web.message.RetDataMsg;

@Router(name="/initial")
public class InitialController extends BaseController {

	@AutoInject
	private AccountService accountService;
	
	@AutoInject
	private UserService userService;
	
	@AutoInject
	private InitialService initialService;
	
	public void index() {
	}

	public void account() {		
		RetDataMsg ajaxMsg = new RetDataMsg(true);
		String orgId = initialService.initOrg();
		initialService.initAccount(orgId);
		ajaxMsg.pushOk("机构超级账户初始化完毕.");
		renderJson(ajaxMsg);
	}
	
	public void resource(){
		RetDataMsg ajaxMsg = new RetDataMsg(true);
		Account account = accountService.findByName("admin");
		initialService.initDictionary();
		initialService.initResource(account.getStr(Account.FK_ORGID), account.getStr(Account.PK_ID));
		ajaxMsg.pushOk("资源权限初始化完毕.");
		renderJson(ajaxMsg);
	}
	
}
